local UIManager = class("UIManager")
local uiManager = CS.UIManager.Instance

-- function UIManager:openWindow(winName)
--     return uiManager:OpenWindows(winName)
-- end

function UIManager:getUICamera()
    return uiManager.UICamera
end

-- function UIManager:popWindow()
--     uiManager:PopWindow()
-- end

-- function UIManager:openPopupView(popupName)
--     return uiManager:OpenPopup(popupName)
-- end

-- function UIManager:openFixUI(name)
--     return uiManager:OpenFixUI(name)
-- end

function UIManager:showTip(text)
    local object = G_ResourceManager:loadUI("FlowText")
    local popupCanvas = uiManager.PopupCanvas
    local GameUtils = require("utils.GameUtils")
    local Vector3 = require("utils.Vector3")
    local flowText = GameUtils.instantiateTo(popupCanvas.transform, object)
    flowText.transform.localPosition = Vector3.new(0, 0, 0)
    flowText.transform.localScale = Vector3.new(1, 1, 1)
    local luaScript = flowText:GetComponent(typeof(CS.LuaBehaviour)):GetScriptEnv()
    luaScript:setTip(text)
end

function UIManager:appendPromptUI()
    local object = G_ResourceManager:loadUI("PromptUI")
    local popupCanvas = uiManager.FixCanvas
    local GameUtils = require("utils.GameUtils")
    local promptUI = GameUtils.instantiateTo(popupCanvas.transform, object)
    return promptUI
end

function UIManager:getFixCanvas()
    return uiManager.FixCanvas
end

function UIManager:getUICanvas()
    return uiManager.UICanvas
end

function UIManager:getPopCanvas()
    return uiManager.PopupCanvas
end

function UIManager:openLoadView()
    G_ResourceManager:LoadFromLocalUpd()
end

function UIManager:isHaveUIInScene()
    local childCount = uiManager.PopupCanvas.transform.childCount
    for i = 0, childCount - 1 do
        local child = uiManager.PopupCanvas.transform:GetChild(i)
        if child.gameObject.active == true then
            return true
        end
    end
    local childCount2 = uiManager.UICanvas.transform.childCount
    for i = 0, childCount2 - 1 do
        local child = uiManager.UICanvas.transform:GetChild(i)
        if child.gameObject.active == true then
            return true
        end
    end
    return false
end

function UIManager:ScreenPointToLocalPointInRectangle(rect, screenPoint, cam)
    return uiManager:ScreenPointToLocalPointInRectangle(rect, screenPoint, cam)
end

return UIManager
